package com.qd.core.dblog.audit;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@RequiredArgsConstructor
@ConditionalOnProperty(
        prefix = "admin-config",
        name = "auditLog",
        havingValue = "true"
)
@Configuration
@Slf4j
public class AuditLogConfig {
    private final StringRedisTemplate stringRedisTemplate;

    @Bean
    public Interceptor auditLogInterceptor() {
        log.info("初始化记录系统审计日志");
        return new AuditLogInterceptor(stringRedisTemplate);
    }
}
